#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "rngs.h"
#include "testhelpers.c"

// tests endGame function

int main(){
    struct gameState *state = malloc(sizeof(struct gameState));
    setState(state);

    resetFlag();
    resetDeck(state);

    printf("Testing End Turn\n");

    // ends turn off of a clean state
    endTurn(state);
    if(state->whoseTurn != 1)
        assertMessage("Current turn should be for %d but is for %d\n", 1, state->whoseTurn);

    endTurn(state);
    if(state->whoseTurn != 0)
        assertMessage("Current turn should be for %d but is for %d\n", 0, state->whoseTurn);


    state->coins = 10;
    state->numActions = 2;
    state->outpostPlayed = 1;
    state->numBuys = 3;
    endTurn(state);

//    if(state->coins != 0)
//        assertMessage("Current coins should be %d but is %d (original 10)\n", 0, state->coins);
//    Since this funciton calls a helper function to count all coins in the hand, we cannot assume we know the state-> coins value

    if(state->numActions != 1)
        assertMessage("Current Actions should be %d but is %d\n", 1, state->numActions);
    if(state->outpostPlayed != 0)
        assertMessage("Current outposts Played should be %d but is %d\n", 0, state->outpostPlayed);
    if(state->numBuys != 1)
        assertMessage("Current buys should be %d but is %d\n", 0, state->numBuys);

    if(testState() == 0)
        printf("End Turn testing passed\n");
    else
        printf("End Turn testing failed\n");

    free(state);
    return 0;
}
